package com.huawei.gamebox.service.welfare.gift.node;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.common.cardkit.card.BaseGsCard;
import com.huawei.gamebox.service.common.cardkit.node.BaseGsNode;
import com.huawei.gamebox.service.welfare.gift.bean.CombineGameGiftListCardBean;
import com.huawei.gamebox.service.welfare.gift.card.CombineGameGiftListCard;
import com.huawei.gamebox.service.welfare.gift.card.GameGiftHorizonScrollCard;
import java.util.List;
import o.azb;
import o.cgz;
import o.chy;
import o.chz;
import o.cih;
import o.CollectCheck;
import o.exp$c;
import o.exp$e;
import o.exp$f;
import o.exp.d;
import o.exp.j;
import o.fcs;

public class CombineGameGiftListNode extends BaseGsNode {
    private chy ˊ;

    public CombineGameGiftListNode(Context context) {
        super(context);
    }

    public int ˏ() {
        return 1;
    }

    public boolean ॱ() {
        return true;
    }

    public boolean ˊ(ViewGroup viewGroup, ViewGroup viewGroup2) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -1);
        layoutParams.weight = 1.0f;
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        cih combineGameGiftListCard = new CombineGameGiftListCard(this.ॱ);
        int i = j.ॱͺ;
        if (ˋ()) {
            i = j.ᐝॱ;
        }
        LinearLayout linearLayout = (LinearLayout) from.inflate(i, null);
        if (!ˋ()) {
            azb.ˏ(linearLayout, d.ˎ);
        }
        TextView textView = (TextView) linearLayout.findViewById(d.ᶥ);
        ˊ(textView);
        if (ˋ()) {
            ((TextView) linearLayout.findViewById(d.ꜞ)).setTextColor(this.ॱ.getResources().getColor(exp$c.ʽ));
            textView.setTextColor(this.ॱ.getResources().getColor(exp$c.ˋ));
            ((ImageView) linearLayout.findViewById(d.ㆍ)).setImageResource(exp$e.ॱˊ);
        }
        combineGameGiftListCard.ˋ(linearLayout);
        ˊ(combineGameGiftListCard);
        viewGroup.addView(linearLayout, layoutParams);
        return true;
    }

    protected void ˊ(TextView textView) {
        textView.setText(this.ॱ.getResources().getString(exp$f.י));
    }

    public boolean ॱ(chz o_chz, ViewGroup viewGroup) {
        this.ˏ = o_chz.ˏ;
        cih ˎ = ˎ(0);
        if (ˎ instanceof CombineGameGiftListCard) {
            CombineGameGiftListCard combineGameGiftListCard = (CombineGameGiftListCard) ˎ;
            CardBean ˋ = o_chz.ˋ(0);
            if (ˋ instanceof CombineGameGiftListCardBean) {
                ˋ.ˋˋ(String.valueOf(this.ˏ));
                List ˊ = ((CombineGameGiftListCardBean) ˋ).ˊ();
                if (CollectCheck.isEmpty(ˊ)) {
                    ˎ.ˉ().setVisibility(8);
                } else {
                    ॱ(combineGameGiftListCard, ˊ.size());
                    ˎ.ˎ(ˋ, viewGroup);
                    ˎ.ˉ().setVisibility(0);
                }
            } else {
                ˎ.ˉ().setVisibility(8);
            }
        }
        return true;
    }

    private void ॱ(CombineGameGiftListCard combineGameGiftListCard, int i) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        LayoutInflater from = LayoutInflater.from(this.ॱ);
        for (int i2 = 0; i2 < i; i2++) {
            View view = (ViewGroup) from.inflate(j.ᐝ, null);
            BaseGsCard gameGiftHorizonScrollCard = new GameGiftHorizonScrollCard(this.ॱ);
            gameGiftHorizonScrollCard.ˊ(view);
            combineGameGiftListCard.ˋ(gameGiftHorizonScrollCard);
            View ˉ = combineGameGiftListCard.ˉ();
            if (ˉ instanceof ViewGroup) {
                ((ViewGroup) ˉ).addView(view, layoutParams);
            }
        }
        ˋ(this.ˊ);
    }

    public void ˋ(chy o_chy) {
        int i = 0;
        this.ˊ = o_chy;
        cgz ˊ = ˊ(0);
        if (ˊ instanceof CombineGameGiftListCard) {
            CombineGameGiftListCard combineGameGiftListCard = (CombineGameGiftListCard) ˊ;
            combineGameGiftListCard.ˏ(o_chy);
            int ˋ = combineGameGiftListCard.ˋ();
            while (i < ˋ) {
                BaseGsCard ˊ2 = combineGameGiftListCard.ˊ(i);
                if (ˊ2 != null) {
                    ˊ2.ॱ(o_chy);
                }
                i++;
            }
            OnClickListener o_fcs = new fcs(o_chy, combineGameGiftListCard, 9);
            combineGameGiftListCard.ˊ().setOnClickListener(o_fcs);
            combineGameGiftListCard.ʻ().setOnClickListener(o_fcs);
        }
    }
}
